﻿Imports JanuControls
Imports EguSoc_Dll

Module Elementos_Comunes
    Public Function Valida_PIN_Socio(ByVal Socio As String) As Int16
        Try
            Dim Frm As New TecladoNumerico

            Frm.Pass = True
            Frm.ShowDialog()

            If Frm.Respuesta Then
                If Frm.Texto <> "" Then
                    If DSEA.Funciones_De_Validacion.F_Valida_Pin(Socio, Frm.Texto) Then
                        Return -1
                    Else
                        Return 0
                    End If
                Else
                    Return 1
                End If
            Else
                Return 1
            End If
        Catch ex As Exception
            Return 0
        End Try
    End Function

    Public Function Valida_Socio(Optional ByRef Grado_Socio As String = "", Optional ByRef Pass As String = "") As Boolean
        Try
            Dim Frm As New FrmUsuarioPin

            Frm.ShowDialog()

            If Frm.Respuesta Then
                Dim TA_Aux As New Socios_TableAdapter
                Dim DT_Aux As New DSEA.SociosDataTable

                TA_Aux.FillBySocioPin(DT_Aux, Frm.Pass, Frm.PIN)

                If DT_Aux.Rows.Count > 0 Then
                    Pass = TryCast(DT_Aux.Rows(0), DSEA.SociosRow).DNI
                    Grado_Socio = TryCast(DT_Aux.Rows(0), DSEA.SociosRow).Permisos
                    Return True
                Else
                    Return False
                End If
            Else
                Return False
            End If
        Catch ex As Exception
            Return False
        End Try
    End Function
End Module
